package com.openbravo.pos.payment;

import java.awt.event.KeyEvent;

public class MagCardReaderAlternative
  implements MagCardReader
{
  private MagCardParser magcardparser = new MagCardParserGeneric();
  private StringBuffer asciiCode = null;

  public String getReaderName()
  {
    return "Alternative magnetic card reader";
  }

  public void keyPressed(KeyEvent paramKeyEvent)
  {
    if (paramKeyEvent.getKeyCode() == 18)
      this.asciiCode = new StringBuffer();
  }

  public void keyReleased(KeyEvent paramKeyEvent)
  {
    if (paramKeyEvent.getKeyCode() == 18)
    {
      if (this.asciiCode != null)
        try
        {
          this.magcardparser.append((char)Integer.parseInt(this.asciiCode.toString()));
        }
        catch (NumberFormatException localNumberFormatException)
        {
        }
      this.asciiCode = null;
    }
  }

  public void keyTyped(KeyEvent paramKeyEvent)
  {
    if ((this.asciiCode != null) && (Character.isDigit(paramKeyEvent.getKeyChar())))
      this.asciiCode.append(paramKeyEvent.getKeyChar());
    else if (paramKeyEvent.getKeyChar() == '\n')
      this.magcardparser.append(paramKeyEvent.getKeyChar());
  }

  public MagCardParser getMagCard()
  {
    return this.magcardparser;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.payment.MagCardReaderAlternative
 * JD-Core Version:    0.6.0
 */